<template>
	<view class="textareaa">
		<!-- -->
		<textarea  placeholder="请输入" v-model="inputValue" :disabled="disabled" :name="name" @blur="_onBlur"></textarea>
	</view>
</template>
<script>
	export default {
		props: {
			value: {
				type: [String],
				default: ""
			},
			name: {
				type: String,
			},
			disabled: {
				type: Boolean,
				default: false
			},
		},
		watch: {
			value(val) {
				// console.log(val)
				this.inputValue = val;
				// console.log(this.inputValue)

			},
			inputValue(newVal, oldVal) {
				// console.log(newVal, oldVal)
				if (+newVal !== +oldVal) {
					// console.log(newVal)
					this.$emit("change", newVal);
				}
			}
		},
		data() {
			return {
				inputValue: ""
			}
		},
		created() {
			// console.log(this.value)
			this.inputValue = this.value;
			
			// console.log(this.value,this.inputValue)
		},
		methods: {
			_onBlur(event) {
				let value = event.detail.value;
				// console.log(value)
				// if (!value) {
				// 	// this.inputValue = 0;
				// 	return;
				// }
				// value = +value;
				// if (value > this.max) {
				// 	value = this.max;
				// } else if (value < this.min) {
				// 	value = this.min;
				// }
				this.inputValue = value;
			}
		}
	}
</script>
<style scoped>
	.textareaa {
		width: 75%;
		/* border: 1px solid red; */
	}
</style>
